package com.cdd.manage.controller;

import com.cdd.manage.mapper.SendmsgBusinessMapper;
import com.cdd.manage.service.SendmsgBusinessService;
import com.cdd.manage.vo.ClientVo;
import com.cdd.manage.vo.SendmsgBusinessVo;
import com.common.entity.SendmsgBusiness;
import com.common.untils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 *
 *
 * @author lenovo
 * @version 1.0
 * @since 2022-09-06  17:00:59
 */
@RestController
@RequestMapping("/manage/manage")
public class SendmsgBusinessController {
    @Autowired
    private SendmsgBusinessService sendmsgBusinessService;
    //查询所有
    @PostMapping("/selectAll/{currentPage}/{pageSize}")
    public CommonResult selectAll(@PathVariable("currentPage") Integer currentPage, @PathVariable("pageSize") Integer pageSize, @RequestBody SendmsgBusinessVo sendmsgBusinessVo,HttpServletRequest request){
        //获取token
        String token = request.getHeader("token");
        return sendmsgBusinessService.selectAll(currentPage,pageSize,sendmsgBusinessVo,token);
    }
    //添加内容--发布通告
    @PostMapping("/insert")
    public CommonResult insert(@RequestBody SendmsgBusiness sendmsgBusiness, HttpServletRequest request){
        //获取token
        String token = request.getHeader("token");
        return sendmsgBusinessService.insert(sendmsgBusiness,token);

    }
    //查询发布的内容
    @PostMapping("/queryCon/{id}")
    public CommonResult query(@PathVariable Integer id){
        return sendmsgBusinessService.query(id);
    }
    //删除
    @PostMapping("/deleteById/{id}")
    public CommonResult deleteById(@PathVariable Integer id){
        return sendmsgBusinessService.deleteById(id);
    }
    //前端--消息中心查询
    @PostMapping("/manageAllById/{currentPage}/{pageSize}")
    public CommonResult manageAllById(@PathVariable("currentPage") Integer currentPage, @PathVariable("pageSize") Integer pageSize,HttpServletRequest request){
        String hometoken = request.getHeader("hometoken");
        return sendmsgBusinessService.manageAllById(currentPage,pageSize,hometoken);
    }
    //前端--消息中心修改状态
    @PostMapping("/updateManage/{id}")
    public CommonResult updateManage(@PathVariable Integer id){
        return sendmsgBusinessService.updateManage(id);
    }
}
